package com.video.server;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class FXServer extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		doPost(req,resp);
			}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		//解决Post提交信息乱码
		//req.setCharacterEncoding("utf-8");
		String dire = req.getParameter("dire");
		//get提交乱码
		dire = new String(dire.getBytes("ISO-8859-1"),"UTF-8");
		System.out.println(dire);
		try {
			Class.forName("com.mysql.jdbc.Driver");
			Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/video","root","123456");
			PreparedStatement ps = conn.prepareStatement("insert v_direction(direction) values(?)");
			ps.setString(1, dire);
			ps.executeUpdate();
			//jsp中写校验
		} catch (Exception e) {
		
			e.printStackTrace();
		}
		
		
		
	}

	
}
